#!/bin/python3
import requests as req
import re
url="https://ipaddress.com/website/github.com"
head={
    "User-Agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0",
}
get=req.get(url)
obj=re.compile(r'<th>IP Address</th>.*?<li>(?P<name>.*?)</li>',re.S)
result=obj.finditer(get.text)
for it in result:
    print(it.group("name"));
    str=it.group("name");
    fp=open("/etc/hosts","r+")
    flist=fp.readlines();
    flist[2]=it.group("name")+" github.com";
    fp.close();
    fp=open("/etc/hosts","w+");
    fp.writelines(flist);
    fp.close();
    print("update github ok\n");
